import request from '@/utils/request.js'
import store from '@/store'
export function authorizations (data) {
  return request({
    url: '/v1_0/authorizations',
    method: 'post',
    noToken: true,
    data
  })
}

export const smsCode = mobile => {
  return request({
    url: `/v1_0/sms/codes/${mobile}`
  })
}

export function userProfile () {
  return request({
    url: '/v1_0/user/profile'
  })
}

// 个人属性
export function userProfilePatch (data) {
  return request({
    url: '/v1_0/user/profile',
    method: 'patch',
    data
  })
}

// 个人资料图片修改
export function userPhotoPatch (data) {
  return request({
    url: '/v1_0/user/photo',
    method: 'patch',
    data
  })
}
// 刷新用户token  /v1_0/authorizations
export function authorizationsPut () {
  return request({
    url: '/v1_0/authorizations',
    method: 'put',
    noToken: true, //不染发请求拦截添加token
    headers: {
      Authorization: `Bearer ${store.state.user.refresh_token}`
    }
  })
}
